import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
// 解决vue路由连点报错问题的方案
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [{
        path: "/",
        redirect: "/login"
    },
    {
        path: '/home',
        name: 'Home',
        component: Home
    },
    {
        path: '/courseadd',
        name: 'courseadd',
        component: () =>
            import ("../views/courseAdd/index.vue")
    },
    {
        path: '/login',
        name: 'Login',
        component: () =>
            import ("../views/login/index.vue")
    },
    {
        path: '/admin',
        name: 'admin',
        component: () =>
            import ("../views/admin/index.vue")
    },
    {
        path: '/student',
        name: 'student',
        component: () =>
            import ("../views/student/index.vue")
    },
    {
        path: "/courseList",
        name: "courseList",
        component: () =>
            import ("../views/courseList/index.vue")
    },
    {
        path: "/video",
        name: "video",
        component: () =>
            import ("../views/video/index.vue")
    },
    {
        path: '/about',
        name: 'About',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
            import ( /* webpackChunkName: "about" */ '../views/About.vue')
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router